package com.ruoyi.labdata.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.labdata.domain.LabOrgnizationThird;
import com.ruoyi.labdata.service.ILabOrgnizationThirdService;

/**
 * 三级机构信息Controller
 * 
 * @author winner pan
 * @date 2022-02-05
 */
@RestController
@RequestMapping("/labdata/orgThird")
public class LabOrgnizationThirdController extends BaseController
{
    @Autowired
    private ILabOrgnizationThirdService labOrgnizationThirdService;

    /**
     * 查询三级机构信息列表
     * 公共资源不设访问权限
     */
    //@PreAuthorize("@ss.hasPermi('labdata:orgThird:query')")
    @GetMapping("/list")
    public TableDataInfo list(LabOrgnizationThird labOrgnizationThird)
    {
        startPage();
        List<LabOrgnizationThird> list = labOrgnizationThirdService.selectLabOrgnizationThirdList(labOrgnizationThird);
        return getDataTable(list);
    }

    /**
     * 导出三级机构信息列表
     */
    //@PreAuthorize("@ss.hasPermi('labdata:orgThird:export')")
    /*@Log(title = "三级机构信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabOrgnizationThird labOrgnizationThird)
    {
        List<LabOrgnizationThird> list = labOrgnizationThirdService.selectLabOrgnizationThirdList(labOrgnizationThird);
        ExcelUtil<LabOrgnizationThird> util = new ExcelUtil<LabOrgnizationThird>(LabOrgnizationThird.class);
        return util.exportExcel(list, "orgThird");
    }*/

    /**
     * 获取三级机构信息详细信息
     * 公共资源不设访问权限
     */
    //@PreAuthorize("@ss.hasPermi('labdata:orgThird:query')")
    @GetMapping(value = "/{labId}")
    public AjaxResult getInfo(@PathVariable("labId") Long labId)
    {
        return AjaxResult.success(labOrgnizationThirdService.selectLabOrgnizationThirdById(labId));
    }

    /**
     * 新增三级机构信息
     */
    @PreAuthorize("@ss.hasPermi('labdata:orgThird:edit')")
    @Log(title = "三级机构信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabOrgnizationThird labOrgnizationThird)
    {
        return toAjax(labOrgnizationThirdService.insertLabOrgnizationThird(labOrgnizationThird));
    }

    /**
     * 修改三级机构信息
     */
    @PreAuthorize("@ss.hasPermi('labdata:orgThird:edit')")
    @Log(title = "三级机构信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabOrgnizationThird labOrgnizationThird)
    {
        return toAjax(labOrgnizationThirdService.updateLabOrgnizationThird(labOrgnizationThird));
    }

    /**
     * 删除三级机构信息
     */
    @PreAuthorize("@ss.hasPermi('labdata:orgThird:edit')")
    @Log(title = "三级机构信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{labIds}")
    public AjaxResult remove(@PathVariable Long[] labIds)
    {
        return toAjax(labOrgnizationThirdService.deleteLabOrgnizationThirdByIds(labIds));
    }
}
